Foundations:
You have a class. This class should be indexable by double index ( [i][j] ). As a single operator, as you have experienced, it isn't possible. However, if you think it's worth the time, you can do the following:
Create a function that does what you need as a normal member function "Indexer( int x, int y )".
Create a single indexer ( [] ), that returns another object of a user defined class. This class defines another indexer that returns the parents class' Indexer function.
Example:
PHP Code:
#include <stdio.h>
class UsesDoubleIndexer
{
public:
class dblidx
{
private:
int m_x;
UsesDoubleIndexer* m_Parent;
public:
dblidx( int x, UsesDoubleIndexer* Parent )
{
m_x = x;
m_Parent = Parent;
}
int operator [] ( int y )
{
return m_Parent.Indexer( m_x, y );
}
}
dblidx operator [] ( int x )
{
return dblidx( x, this );
}
int Indexer( int x, int y )
{
// your indexer function here
return 2*x+y;
}
};
int main()
{
UsesDoubleIndexer udi;
printf("%d", udi[0][3] );
return 0;
}
I've no compiler handy... so this is just an educated guess